import React from 'react'
import './style.scss'
import Icon from '../Icon'
import { useLocation, useNavigate } from 'umi'
// 利用uselocation获取参数信息，取当前路由的路径作为判断依据
let routerName = (a)=>{
  
  let name
  switch (a){
    case '/home' : name='首页'; break;
    case '/cart' : name='购物车'; break;
    case '/cate' : name='分类'; break;
    case '/user' : name='用户个人'; break;
    case '/login' : name='登录页'; break;
    case '/reg' : name='注册页'; break;
    default : name='404'; break 
  }
  return name
}
export default function index() {
  const navigate = useNavigate()
  return (
    <div className='header'>
      <Icon name="fanhui" size={22} color="#333" onClick={()=>{
        navigate(-1)
      }}/>
      <span>{routerName(useLocation().pathname)}</span>
      <Icon name="kefu" size={22} color="#333"/>
    </div>
  )
}
